#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;

const ll N = 2e5 + 10, INF = 0x3f3f3f3f;

ll n, s, x;
ll a[N];
map<ll, ll> hs;

void solve()
{
    hs.clear();
    cin >> n >> s >> x;
    for (ll i = 1;i <= n;i++) {
        ll c;cin >> c;
        a[i] = a[i - 1] + c;
    }
    ll l = 0, ans = 0;
    for (ll r = 1;r <= n;r++) {
        if (a[r] - a[r - 1] > x) {
            hs.clear();
            l = r;
        } else if (a[r] - a[r - 1] == x) {
            while (l < r) { hs[a[l]]++; l++; }
        }
        ans += hs[a[r] - s];
    }
    cout << ans << '\n';
}

signed main()
{
    // ios::sync_with_stdio(0);
    // cin.tie(0);cout.tie(0);
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
    std::istringstream in(R"(3 -1 -1
-1 1 -1)");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll T = 1;
    cin >> T;
    for (ll i = 1;i <= T;i++) {
        solve();
    }
}